﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/SiteMaster.master"
    CodeBehind="ViewQRCodes.aspx.cs" Inherits="CivilleWebRole.ViewQRCodes" %>

<%@ Register Assembly="CivilleWebRole" Namespace="CivilleWebRole" TagPrefix="cc1" %>
<asp:Content ID="HeaderContent" ContentPlaceHolderID="HeadContent" runat="Server">
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="BodyContent" runat="Server">
    <table style="width: 100%;">
        <tr>
            <td>
                <h2>
                    Select a task:
                </h2>
            </td>
        </tr>
        <tr>
            <td>
                <asp:DropDownList ID="TasksDDL" runat="server" DataSourceID="TasksDataSource" DataTextField="Title"
                    DataValueField="ID" OnPreRender="GenerateQRCodes" OnTextChanged="GenerateQRCodes"
                    AutoPostBack="true">
                </asp:DropDownList>
                <asp:SqlDataSource ID="TasksDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:CivilleConnectionString %>"
                    SelectCommand="SELECT [Task].[ID], [Task].[Title], [Stakeholder].[ID], [Stakeholder].[Name] FROM [Task], [Stakeholder] WHERE ([Stakeholder].[Name] = @Name AND [Task].[StakeholderID] = [Stakeholder].[ID])">
                    <SelectParameters>
                        <cc1:UserParameter Name="Name" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
                <asp:GridView ID="QRCodesGridView" runat="server" DataSourceID="QRCodeDataSource"
                    AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True">
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="Code" HeaderText="Code" SortExpression="Code" />
                        <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="QRCodeDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:CivilleConnectionString %>"
                    SelectCommand="SELECT Code, Status FROM QRCode WHERE TaskID = @ID">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="TasksDDL" Name="ID" PropertyName="SelectedValue"
                            Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
    </table>
    <p>To view a QR code for scanning, use services like: <a>http://qrcode.kaywa.com/</a>. Remember, use codes that have status set to True!</p>
</asp:Content>
